package com.pagoda.nerp.web.util;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;


/**
 * @Author:HXB
 * @Description
 * @Date Create in 11:29 2017/12/27
 * @Modified By
 **/
public class DatetimeAdapter extends XmlAdapter<String,Date> {
    private SimpleDateFormat format = new SimpleDateFormat(
            "yyyy-MM-dd't'HH:mm:ss'+08:00'"
    );

    @Override
    public Date unmarshal(String time) throws Exception {
        if( null ==time){
            return null;
        }
        return format.parse(time);
    }

    @Override
    public String marshal(Date date){
        return format.format(date);
    }
}
